<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class LogInfo extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'PetsTask {task} {param?}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'PetsTask harbor';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $task = $this->argument('task');
        $param = $this->argument('param') ?? "";
        $map = [
            //每小时运行一次-获取微信的access_token
            'server:getWechatToken' => "App\Services\Async\PetsService::getWechatToken",

            //每分钟一次-关闭超过半小时没有支付的订单
            'server:closeOrder' => "App\Services\Async\PetsService::closeOrder",

            //任务到达计划结束时间状态变成完成
            'server:publishTask' => "App\Services\Async\PetsService::publishTask",

        ];
        if (in_array($task, array_keys($map))) {
            $map[$task]($param);
        }
        return true;
    }
}
